<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" template="/paginas/template.xhtml">



	<ui:define name="corpoForm">


		<h:form id="formBotoesBlackList" prependId="false">
			<p:panelGrid columns="1" styleClass="botoes" id="botoes">
				<p:commandButton id="botaoCriarBlackList" value="#{rsc.label_criar}"
					rendered="#{p:ifGranted('CRIAR_BLACKLIST')}" styleClass="botao"
					action="#{manterBlackListBean.criarEntidade}" ajax="false"
					title="#{rsc.title_criar}" />
			</p:panelGrid>
		</h:form>

		<f:event type="javax.faces.event.PreRenderComponentEvent"
			listener="#{manterBlackListBean.preRenderList}" />
		<h:form id="formListBlackLists" prependId="false">

			<p:fieldset legend="#{rsc.label_filtros}" toggleable="true"
				collapsed="true">
				<p:panelGrid columns="5">
					<p:outputLabel value="#{rsc.label_blackList} " for="acBlackList" />

					<p:outputLabel value="#{rsc.label_numeroBlackList} "
						for="txtNumeroBlackList" />

					<p:outputLabel value="#{rsc.label_email} " for="txtEmailBlackList" />

					<p:outputLabel value="#{rsc.label_ativo}" for="cmbAtivo" />

					<p:spacer />

					<p:autoComplete id="acBlackList" minQueryLength="3" size="34"
						value="#{manterBlackListBean.filtro.nome}" effect="fade"
						maxResults="7"
						completeMethod="#{manterBlackListBean.autoCompleteNome}">
						<p:ajax event="change"
							listener="#{manterBlackListBean.buscarPorFiltros}"
							update="listaBlackLists" />
					</p:autoComplete>

					<p:inputText label="#{rsc.label_blackList}" id="txtNumeroBlackList"
						maxlength="60" size="20" title="#{rsc.label_numeroBlackList}"
						value="#{manterBlackListBean.entidade.celular}" />

					<p:inputText label="#{rsc.label_email}" id="txtEmailBlackList"
						maxlength="60" size="19" title="#{rsc.label_blackList}"
						value="#{manterBlackListBean.entidade.email}" />


					<p:selectOneMenu label="#{rsc.label_ativo}"
						value="#{manterBlackListBean.filtro.ativo}" id="cmbAtivo">
						<p:ajax event="change"
							listener="#{manterBlackListBean.buscarPorFiltros}"
							update="listaBlackLists" />
						<f:selectItem itemLabel="#{rsc.label_selecionar}" itemValue="" />
						<f:selectItems value="#{manterBlackListBean.status}" var="c"
							itemLabel="#{c.label}" itemValue="#{c}" />
					</p:selectOneMenu>

					<p:commandButton update="listaBlackLists"
						actionListener="#{manterBlackListBean.buscarPorFiltros}"
						icon="ui-icon ui-icon-search" title="#{rsc.label_buscar}" />
				</p:panelGrid>
			</p:fieldset>
			<p:watermark value="#{rsc.wm_nomeBlackListConsulta}"
				for="acBlackList" />
			<p:watermark value="#{rsc.wm_emailBlackListConsulta}"
				for="txtEmailBlackList" />
			<p:watermark value="#{rsc.wm_numeroBlackListConsulta}"
				for="txtNumeroBlackList" />

			<p:panel id="pnlListaBlackLists"
				header="#{rsc.label_blackListsCadastradas}" toggleable="true"
				toggleSpeed="500">

				<p:panelGrid columns="1" styleClass="full-width"
					columnClasses="full-width">
					<p:dataTable emptyMessage="#{msg.nenhumRegistroEncontrado}"
						var="blackList" id="listaBlackLists" sortMode="multiple"
						widgetVar="listaBlackListsWid"
						value="#{manterBlackListBean.entidades}" paginator="true"
						rows="10" paginatorPosition="#{rsc.label_paginationPosition}"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="10,50,150,200">

						<p:column headerText="#{rsc.label_blackList}"
							sortBy="#{blackList.nome}">
							<p:outputLabel value="#{blackList.nome}" />
						</p:column>
						
						
						<p:column headerText="#{rsc.label_numeroBlackList}"
							sortBy="#{blackList.celular}">
							<p:outputLabel value="#{blackList.celular}" />
						</p:column>
						
						
						<p:column headerText="#{rsc.label_email}"
							sortBy="#{blackList.email}">
							<p:outputLabel value="#{blackList.email}" />
						</p:column>
						

						<p:column headerText="#{rsc.label_ativo}"
							sortBy="#{blackList.ativo}" styleClass="centralizado">
							<p:outputLabel value="#{rsc.label_sim}"
								rendered="#{blackList.ativo}" />
							<p:outputLabel value="#{rsc.label_nao}"
								rendered="#{!blackList.ativo}" />
						</p:column>


						<p:column styleClass="coluna-acoes"
							headerText="#{rsc.label_acoes}">

							<p:commandButton update=":habilitarDialog"
								rendered="#{p:ifGranted('HABILITAR_BLACKLIST') and !blackList.ativo}"
								oncomplete="habilitar.show();" icon="ui-icon ui-icon-locked"
								title="#{rsc.label_habilitar}">
								<f:setPropertyActionListener value="#{blackList}"
									target="#{manterBlackListBean.entidade}" />
							</p:commandButton>

							<p:commandButton update=":desabilitarDialog"
								rendered="#{p:ifGranted('HABILITAR_BLACKLIST') and blackList.ativo}"
								oncomplete="desabilitar.show();" icon="ui-icon ui-icon-unlocked"
								title="#{rsc.label_desabilitar}">
								<f:setPropertyActionListener value="#{blackList}"
									target="#{manterBlackListBean.entidade}" />
							</p:commandButton>

							<p:commandButton icon="ui-icon ui-icon-pencil"
								rendered="#{p:ifGranted('ALTERAR_BLACKLIST')}"
								title="#{rsc.label_editar}" ajax="false"
								action="editarBlackList">
								<f:setPropertyActionListener value="#{blackList}"
									target="#{manterBlackListBean.entidade}" />
							</p:commandButton>

						</p:column>
					</p:dataTable>
				</p:panelGrid>
			</p:panel>

		</h:form>

		<p:confirmDialog message="#{msg.questionConfirmaHabilitar}"
			appendTo="@(body)" width="250" id="habilitarDialog"
			header="#{rsc.label_confirmar}" severity="alert"
			widgetVar="habilitar">
			<h:form id="habilitarForm">
				<p:commandButton value="#{rsc.label_sim}" styleClass="botao"
					actionListener="#{manterBlackListBean.habilitar}"
					oncomplete="habilitar.hide()"
					update=":formListBlackLists:listaBlackLists, :growl" />
				<p:commandButton value="#{rsc.label_nao}" styleClass="botao"
					onclick="habilitar.hide()" type="button" />
			</h:form>
		</p:confirmDialog>

		<p:confirmDialog message="#{msg.questionConfirmaDesabilitar}"
			appendTo="@(body)" width="250" id="desabilitarDialog"
			header="#{rsc.label_confirmar}" severity="alert"
			widgetVar="desabilitar">
			<h:form id="desabilitarForm">
				<p:commandButton value="#{rsc.label_sim}" styleClass="botao"
					actionListener="#{manterBlackListBean.desabilitar}"
					oncomplete="desabilitar.hide()"
					update=":formListBlackLists:listaBlackLists, :growl" />
				<p:commandButton value="#{rsc.label_nao}" styleClass="botao"
					onclick="desabilitar.hide()" type="button" />
			</h:form>
		</p:confirmDialog>

	</ui:define>
</ui:composition>

